package com.example.newland.application;

import com.nle.mylibrary.databus.DataBus;
import com.nle.mylibrary.databus.DataBusFactory;
import com.nle.mylibrary.databus.ReciveData;
import com.nle.mylibrary.device.GenericConnector;
import com.nle.mylibrary.device.RFID;
import com.nle.mylibrary.device.ZigBee;
import com.nle.mylibrary.device.ZigBee3;
import com.nle.mylibrary.device.listener.ConnectResultListener;

public class EpcInit {

    private static DataBus dataBus1;
    private static DataBus dataBus2;
    private static DataBus dataBus3;
    private static RFID rfid;
    private static GenericConnector genericConnector;

    public static RFID epc1(){

        if(rfid == null){

            dataBus1 = DataBusFactory.newSocketDataBus("172.18.3.15", 6001);

            dataBus1.setReciveDataListener(new ReciveData() {
                @Override
                public String getReciveData(byte[] bytes) {
                    return null;
                }
            });
                rfid = new RFID(dataBus1, new ConnectResultListener() {
                    @Override
                    public void onConnectResult(boolean b) {

                    }
                });
                }
//                dataBus1.close();
//                rfid.stopConnect();

        return rfid;
    }


    public static GenericConnector epc2(){

        if(genericConnector == null){

            dataBus2 = DataBusFactory.newSocketDataBus("172.18.3.15", 6005);

            dataBus2.setReciveDataListener(new ReciveData() {
                @Override
                public String getReciveData(byte[] bytes) {
                    return null;
                }
            });
            genericConnector = new GenericConnector(dataBus1, new ConnectResultListener() {
                @Override
                public void onConnectResult(boolean b) {

                }
            });
        }

        return genericConnector;
    }



}
